package com.linzm.leetcode.primary.链表;

/**
 * @Author zimingl
 * @Date 2022/10/6 20:40
 * @Description: TODO
 */
public class 链表206反转链表 {

    public ListNode reverseList(ListNode head) {
        ListNode prev = null;
        ListNode cur = head;
        ListNode temp = null;
        while (cur != null) {
            temp = cur.next;// 保存下一个节点
            cur.next = prev;
            prev = cur;
            cur = temp;
        }
        return prev;
    }
}
